﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using DataContext;

namespace BusinessLogic
{
	public class ServiceBusiness
    {
        #region Field
        ServiceContext serviceContext = new ServiceContext();
        #endregion

        #region Constructors
        public ServiceBusiness() {}
		#endregion

		#region Business Methods
        
        /// <summary>
        /// Kiểm tra đã tồn tại Link dịch vụ hay chưa ?
        /// </summary>
        /// <param name="serviceURL"></param>
        /// <returns>#0: Tồn tại</returns>
        public int CheckExistsServiceURL(string serviceURL)
        {
            try
            {
                return serviceContext.CheckExistsServiceURL(serviceURL);
            }
            catch (System.Exception)
            {
                return 0;
            }
        }

        /// <summary>
        /// Cập nhật Trạng thái Dịch vụ
        /// </summary>
        /// <param name="serviceID"></param>
        /// <returns></returns>
        public bool UpdateStatus(int serviceID)
        {
            try
            {
                return serviceContext.UpdateStatus(serviceID);
            }
            catch (System.Exception)
            {
                return false;
            }
        }
        

        /// <summary>
        /// Lấy ServiceID theo ServiceURL
        /// </summary>
        /// <param name="serviceURL"></param>
        /// <returns></returns>
        public int SelectServiceID(string serviceURL)
        {
            try
            {
                return serviceContext.SelectServiceID(serviceURL);
            }
            catch (System.Exception)
            {
                return 0;
            }
        }
		#endregion
	}
}
